<template>
    <div>
        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>订单管理</el-breadcrumb-item>
            <el-breadcrumb-item>订单列表</el-breadcrumb-item>
        </el-breadcrumb>
        <el-card>
            <el-row>
                <el-col :span='8'>
                    <el-input placeholder="请输入内容" class="input-with-select">
                        <el-button slot="append" icon="el-icon-search"></el-button>
                    </el-input>
                </el-col>
            </el-row>
            <el-table :data="orderList" style="width: 100%" stripe>
                <el-table-column type='index' width="180">
                </el-table-column>
                <el-table-column prop="order_number" label="订单编号" width="180">
                </el-table-column>
                <el-table-column prop="order_price" label="订单价格">
                </el-table-column>
                <el-table-column prop="pay_status" label="是否付款">
                    <template slot-scope='scope'>
                        <el-tag type='success' v-if="scope.row.pay_status==='1'">已付款</el-tag>
                        <el-tag v-else type='danger'>未付款</el-tag>
                    </template>
                </el-table-column>
                <el-table-column prop="is_send" label="是否发货">
                </el-table-column>
                <el-table-column prop="update_time" label="下单时间">
                    <template slot-scope='scope'>
                        {{scope.row.update_time|dateFormat}}
                    </template>
                </el-table-column>
                <el-table-column label="操作">
                    <template>
                        <el-button @click='dialogVisible=true' size='mini' type="primary" icon="el-icon-edit">
                        </el-button>
                        <el-button @click='showProcessDialog' size='mini' type="success" icon="el-icon-location"></el-button>
                    </template>
                </el-table-column>
            </el-table>
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                :current-page="queryInfo.pagenum" :page-sizes="[3, 5, 10, 15]" :page-size="queryInfo.pagesize"
                layout="total, sizes, prev, pager, next, jumper" :total="total">
            </el-pagination>
        </el-card>
        <el-dialog title="修改地址" :visible.sync="dialogVisible" width="50%">
            <el-form ref="addFormRef" :model="addForm" :rules='addFormRules' label-width="100px">
                <el-form-item label="省市区/县：" prop='address1'>
                    <el-input v-model="addForm.address1"></el-input>
                </el-form-item>
                <el-form-item label="详细地址：" prop='address2'>
                    <el-input v-model="addForm.address2"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
            </span>
        </el-dialog>
        <el-dialog title="物流进度" :visible.sync="processDialogVisible" width="50%" >
            <span>{{processInfo}}</span>
        </el-dialog>
    </div>
</template>
<script>
    export default {
        name: 'Orders',
        data() {
            return {
                queryInfo: {
                    query: '',
                    pagenum: 1,
                    pagesize: 10
                },
                orderList: [],
                total: 0,
                dialogVisible: false,
                addForm: {
                    address1: '',
                    address2: ''
                },
                addFormRules: {
                    address1: [
                        { required: true, message: '请输入所在地区', trigger: 'blur' },
                    ],
                    address2: [
                        { required: true, message: '请输入详细地址', trigger: 'blur' },
                    ]
                },
                processDialogVisible:false,
                processInfo:[]
            }
        },
        methods: {
            getOrderList() {
                this.$http.get('orders', {
                    params: this.queryInfo
                }).then(res => {
                    // console.log(res)
                    this.orderList = res.data.data.goods
                    this.total = res.data.data.total
                })
            },
            handleSizeChange(newSize) {
                this.queryInfo.pagesize = newSize
                this.getOrderList()
            },
            handleCurrentChange(nweNum) {
                this.queryInfo.pagenum = nweNum
                this.getOrderList()
            },
            showProcessDialog(){
                this.$http.get('kuaidi/804909574412544580')
                .then(res=>{
                    
                    this.processInfo=res.data.data
                })
                this.processDialogVisible=true
            }
        },
        created() {
            this.getOrderList()
        },
    }
</script>
<style>

</style>